<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    function set(){
      const width = document.documentElement.clientWidth
      const size = (20 * width / 320) > 40 ? 40 : (20 * width / 320)
      document.documentElement.style.fontSize = size + 'px'
    }
    window.addEventListener('resize', set)
    window.addEventListener('load', set)
  </script>
</head>
<body>
  123
</body>
</html>
